﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace PlutoStudio.Data.MSSQL
{
    public class MSSQLProvider:Common.ISqlClientProvider
    {
        public System.Data.Common.DbConnection GetConnection(string connectionString)
        {
            return new SqlConnection(connectionString);
        }

        public System.Data.Common.DbParameter GenerateParameter<T>(T item, Common.PropertyItem column)
        {
            var parameterName=string.Format("@{0}",column.ColumnName);
            var parameterValue=column.Property.GetValue(item,null);
            return new SqlParameter(parameterName,parameterValue);
        }

        public System.Data.Common.DbParameter GenerateParameter(Common.PropertyItem column, object value)
        {
            var parameterName = string.Format("@{0}", column.ColumnName);
            return new SqlParameter(parameterName, value);
        }
        public string GenerateIdentifier(string name)
        {
            return string.Format("[{0}]", name);
        }

        public string GenerateParameterName(string name)
        {
            return string.Format("@{0}", name);
        }


    }
}
